swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.62k stars 10.37k forks source link

[SR-4507] "Bad base type" when extending generic typealias #47084

Open dabrahams opened 7 years ago

dabrahams commented 7 years ago
Previous ID SR-4507
Radar None
Original Reporter @dabrahams
Type Bug
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, CompilerCrash | |Assignee | None | |Priority | Medium | md5: be9b377686d0e1cadf7e1b8fce179df0

Issue Description:

This probably reproduces with master, so try that first:

with 5c2cdbc3d0 from the unicode-rethink branch in github, compile the following:

protocol P {  }
struct X<T> {
  struct Y<U> {

  }
  typealias Z = Y<T>
}

extension X.Z : P {  }
['/Users/dave/src/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/bin/swift', '-sdk', '/Applications/Xcode-8E161.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk', 'z.swift']
Bad base type
UNREACHABLE executed at /Users/Shared/dabrahams/s/swift/lib/AST/Type.cpp:3136!
0  swift                    0x0000000103575d68 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x0000000103576416 SignalHandler(int) + 454
2  libsystem_platform.dylib 0x00007fffc5b36b3a _sigtramp + 26
3  libsystem_platform.dylib 0x0000000100000001 _sigtramp + 978097377
4  libsystem_c.dylib        0x00007fffc59bb420 abort + 129
5  swift                    0x0000000103513347 llvm::llvm_unreachable_internal(char const*, char const*, unsigned int) + 471
6  swift                    0x0000000101238fba swift::TypeBase::getContextSubstitutions(swift::DeclContext const*, swift::GenericEnvironment*) + 1002
7  swift                    0x0000000101234c73 swift::TypeBase::getContextSubstitutionMap(swift::ModuleDecl*, swift::DeclContext const*, swift::GenericEnvironment*) + 67
8  swift                    0x00000001010ed5ef swift::TypeChecker::substMemberTypeWithBase(swift::ModuleDecl*, swift::TypeDecl*, swift::Type) + 303
9  swift                    0x00000001010b1b0c swift::TypeChecker::lookupMemberType(swift::DeclContext*, swift::Type, swift::Identifier, swift::OptionSet<swift::NameLookupFlags, unsigned int>) + 972
10 swift                    0x00000001010eef12 resolveIdentTypeComponent(swift::TypeChecker&, swift::DeclContext*, llvm::ArrayRef<swift::ComponentIdentTypeRepr*>, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, bool, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 1122
11 swift                    0x00000001010ee762 swift::TypeChecker::resolveIdentifierType(swift::DeclContext*, swift::IdentTypeRepr*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, bool, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 146
12 swift                    0x00000001010ef5c3 (anonymous namespace)::TypeResolver::resolveType(swift::TypeRepr*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>) + 195
13 swift                    0x00000001010ef4cd swift::TypeChecker::resolveType(swift::TypeRepr*, swift::DeclContext*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 173
14 swift                    0x00000001010edfdb swift::TypeChecker::validateType(swift::TypeLoc&, swift::DeclContext*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 331
15 swift                    0x00000001010fa7a6 bindExtensionDecl(swift::ExtensionDecl*, swift::TypeChecker&) + 102
16 swift                    0x00000001010ff55b void llvm::function_ref<void (std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>)>::callback_fn<swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int)::$_2>(long, std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>) + 123
17 swift                    0x000000010112248b bool llvm::function_ref<bool (std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>)>::callback_fn<swift::FileUnit::forAllVisibleModules(llvm::function_ref<void (std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>)>)::'lambda'(std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>)>(long, std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>) + 59
18 swift                    0x00000001012078ff swift::ModuleDecl::forAllVisibleModules(llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, bool, llvm::function_ref<bool (std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>)>) + 527
19 swift                    0x0000000101207a83 swift::FileUnit::forAllVisibleModules(llvm::function_ref<bool (std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>)>) + 83
20 swift                    0x00000001010fbc7e swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) + 1422
21 swift                    0x0000000100cf36a0 swift::CompilerInstance::performSema() + 3616
22 swift                    0x0000000100245aed swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4621
23 swift                    0x0000000100202240 main + 3312
24 libdyld.dylib            0x00007fffc5927235 start + 1
25 libdyld.dylib            0x0000000000000009 start + 980258261
Stack dump:
0.  Program arguments: /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/bin/swift -frontend -interpret z.swift -enable-objc-interop -sdk /Applications/Xcode-8E161.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -module-name z 
1.  While resolving type X.Z at [z.swift:9:11 - line:9:13] RangeText="X.Z"

Other hashes

clang                              fc6023397f Merge remote-tracking branch 'origin/swift-4.0-branch' into stable
cmark                              d875488 Merge pull request #&#8203;4 from llvm-beanz/generate-cmark-exports
compiler-rt                        fef6bcb58 Merge remote-tracking branch 'origin/swift-4.0-branch' into stable
llbuild                            c1b6082 Merge pull request #&#8203;132 from ddunbar/dir-tree-edges
lldb                               17d86c4ed Merge remote-tracking branch 'origin/swift-4.0-branch' into stable
llvm                               f9ad68050ed Merge remote-tracking branch 'origin/swift-4.0-branch' into stable
ninja                              0b0374e Merge pull request #&#8203;1255 from tchajed/bind-localhost
swift                              54989ac7ea WIP
swift-corelibs-foundation          a7a902a Merge pull request #&#8203;930 from phausler/data_slice_iteration
swift-corelibs-libdispatch         a69853f Merge pull request #&#8203;234 from linux-on-ibm-z/fix_compile_error
swift-corelibs-xctest              50cc074 XCTestAssertNoThrow (#184)
swift-integration-tests            8ae3586 Merge pull request #&#8203;18 from apple/disable-lldb-test
swift-xcode-playground-support     9e980f2 Temporary disable test to get the incremental bot blue again
swiftpm                            3b16c3f7 Merge pull request #&#8203;1062 from aciidb0mb3r/package-graph-dep-fix
belkadan commented 7 years ago

Yep, it does reproduce on master, with the same backtrace. @slavapestov, does this look familiar?