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

Crash on accessing type alias through protocol-type instance

    XMLWordPrintable

    Details

      Description

      Discussion

      protocol P { typealias E = Int }
      func foo(arg: P) {
        print(arg.E.self) // Crash
      }
      

       

      Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file /Users/spestov/src/llvm/include/llvm/Support/Casting.h, line 255.
      Stack dump:
      0.	Program arguments: /Users/spestov/src/build/Ninja-RelWithDebInfoAssert/swift-macosx-x86_64/bin/swift -frontend -c -primary-file a.swift -target x86_64-apple-darwin18.2.0 -enable-objc-interop -color-diagnostics -module-name a -o /var/folders/wg/nmvf884n4b14lt0yw4khjsv00000gn/T/a-a5c34f.o 
      1.	While type-checking 'foo(arg:)' (at a.swift:2:1)
      2.	While type-checking statement at [a.swift:2:18 - line:4:1] RangeText="{
        print(arg.E.self)
      "
      3.	While type-checking expression at [a.swift:3:3 - line:3:19] RangeText="print(arg.E.self"
      0  swift                    0x00000001080d9a78 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
      1  swift                    0x00000001080d8cf5 llvm::sys::RunSignalHandlers() + 85
      2  swift                    0x00000001080da082 SignalHandler(int) + 258
      3  libsystem_platform.dylib 0x00007fff5f09db3d _sigtramp + 29
      4  libsystem_platform.dylib 0x0000000000003e88 _sigtramp + 2700501864
      5  libsystem_c.dylib        0x00007fff5ef5b1c9 abort + 127
      6  libsystem_c.dylib        0x00007fff5ef23868 basename_r + 0
      7  swift                    0x00000001052ffb28 (anonymous namespace)::ExprRewriter::coerceObjectArgumentToType(swift::Expr*, swift::Type, swift::ValueDecl*, swift::AccessSemantics, swift::constraints::ConstraintLocatorBuilder) + 1080
      8  swift                    0x00000001052eca8b (anonymous namespace)::ExprRewriter::buildMemberRef(swift::Expr*, swift::Type, swift::SourceLoc, swift::constraints::OverloadChoice, swift::DeclNameLoc, swift::Type, swift::constraints::ConstraintLocatorBuilder, swift::constraints::ConstraintLocatorBuilder, bool, swift::FunctionRefKind, swift::AccessSemantics, bool) + 2475
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              rahulrrixe Rahul Ranjan
              Reporter:
              anthonylatsis Anthony Latsis
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: