Uploaded image for project: 'Swift'
  1. Swift
  2. SR-3492

Unexpected inheritance of nested types

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: Compiler
    • Labels:
      None
    • Environment:

      Swift 3.0.2

      Description

      The nested enum type inherits it's options, while it shouldn't inherit anything.

      This code should compile without errors:

      class A {
      	enum Reusable {
      		case option1
      	}
      }
      
      class B: A {
      	enum Reusable {
      		case option1
      	}
      	
      	func process() {
      		_ = B.Reusable.option1
      		
      		//		Untitled.swift:13:9: error: ambiguous use of 'option1'
      		//				_ = B.Reusable.option1 // how this is ambiguous?
      		//				      ^
      		//		Untitled.swift:9:8: note: found this candidate
      		//				case option1
      		//				     ^
      		//		Untitled.swift:3:8: note: found this candidate
      		//				case option1
      		//				     ^
      		
      	}
      }
      
      let a = A()
      let b = B()
      

      https://gist.github.com/krzyzanowskim/d02732571b45902154dcf3939a735eb7

      this code souldn't compile

      class A {
      	enum Reusable {
      		case option1
      	}
      }
      
      class B: A {
      	enum Reusable { }
      }
      
      let _ = A.Reusable.option1
      let _ = B.Reusable.option1 // wat???
      

        Attachments

          Activity

            People

            • Assignee:
              slavapestov Slava Pestov
              Reporter:
              krzyzanowskim Marcin Krzyzanowski
            • Votes:
              3 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated: