Xcode 7.0 (7A120f): [Swift] Using a static property of a type defined in a framework in an initializer crashes the compiler
| Originator: | janoschhildebrand | ||
| Number: | rdar://21329977 | Date Originated: | 11-Jun-2015 |
| Status: | Closed | Resolved: | Duplicate of 20193168 |
| Product: | Developer Tools | Product Version: | Xcode 7.0 (7A120f) |
| Classification: | Serious Bug | Reproducible: | Always |
Summary:
The following crashes the Swift compiler:
struct AnotherType {
init() {
let crash = OffendingType.staticMember // Crash
}
}
// Defined in a framework
public struct OffendingType {
public static let staticMember = OffendingType()
}
An example project & crash log are attached to reproduce the issue.
Stack trace:
Assertion failed: (GetSetInfo.getInt().hasValue()), function getSetterAccessibility, file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-700.0.38.1/src/swift/include/swift/AST/Decl.h, line 4044.
0 swift 0x000000010670be0b llvm::sys::PrintStackTrace(__sFILE*) + 43
1 swift 0x000000010670c54b SignalHandler(int) + 379
2 libsystem_platform.dylib 0x00007fff97ff8eaa _sigtramp + 26
3 libsystem_platform.dylib 0x00007ffeaa881278 _sigtramp + 310936552
4 libsystem_c.dylib 0x00007fff97a9a85f abort + 129
5 libsystem_c.dylib 0x00007fff97a61ea8 basename + 0
6 swift 0x0000000104ec7390 void filterForDiscriminator<swift::ValueDecl*>(llvm::SmallVectorImpl<swift::ValueDecl*>&, swift::DebuggerClient*) + 0
7 swift 0x0000000104d8dc14 swift::TypeChecker::getUnopenedTypeOfReference(swift::ValueDecl*, swift::Type, swift::DeclContext*, swift::DeclRefExpr const*, bool) + 180
8 swift 0x0000000104cf0249 swift::constraints::ConstraintSystem::getTypeOfMemberReference(swift::Type, swift::ValueDecl*, bool, bool, swift::constraints::ConstraintLocatorBuilder, swift::DeclRefExpr const*, swift::constraints::DependentTypeOpener*) + 857
9 swift 0x0000000104cf1810 swift::constraints::ConstraintSystem::resolveOverload(swift::constraints::ConstraintLocator*, swift::Type, swift::constraints::OverloadChoice) + 800
10 swift 0x0000000104d45e5f swift::constraints::ConstraintSystem::simplifyConstraint(swift::constraints::Constraint const&) + 1023
11 swift 0x0000000104cee2fc swift::constraints::ConstraintSystem::addConstraint(swift::constraints::Constraint*, bool, bool) + 28
12 swift 0x0000000104cf148b swift::constraints::ConstraintSystem::addOverloadSet(swift::Type, llvm::ArrayRef<swift::constraints::OverloadChoice>, swift::constraints::ConstraintLocator*, swift::constraints::OverloadChoice*) + 395
13 swift 0x0000000104d43ce7 swift::constraints::ConstraintSystem::simplifyMemberConstraint(swift::constraints::Constraint const&) + 7527
14 swift 0x0000000104d45aac swift::constraints::ConstraintSystem::simplifyConstraint(swift::constraints::Constraint const&) + 76
15 swift 0x0000000104cee2fc swift::constraints::ConstraintSystem::addConstraint(swift::constraints::Constraint*, bool, bool) + 28
16 swift 0x0000000104d27922 swift::ASTVisitor<(anonymous namespace)::ConstraintGenerator, swift::Type, void, void, void, void, void>::visit(swift::Expr*) + 4690
...
Steps to Reproduce:
...
17 swift 0x0000000104d2b43b (anonymous namespace)::ConstraintWalker::walkToExprPost(swift::Expr*) + 75
18 swift 0x0000000104e3faec swift::Expr::walk(swift::ASTWalker&) + 76
19 swift 0x0000000104d261e9 swift::constraints::ConstraintSystem::generateConstraints(swift::Expr*) + 201
20 swift 0x0000000104d7c4fb swift::TypeChecker::solveForExpression(swift::Expr*&, swift::DeclContext*, swift::Type, swift::Type, bool, swift::FreeTypeVariableBinding, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem&, llvm::SmallVectorImpl<swift::constraints::Solution>&) + 203
21 swift 0x0000000104d81dc3 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::Type, swift::Type, bool, swift::FreeTypeVariableBinding, swift::ExprTypeCheckListener*) + 243
22 swift 0x0000000104d828bb swift::TypeChecker::typeCheckBinding(swift::Pattern*&, swift::Expr*&, swift::DeclContext*) + 107
23 swift 0x0000000104d82a54 swift::TypeChecker::typeCheckPatternBinding(swift::PatternBindingDecl*, unsigned int) + 244
24 swift 0x0000000104d9dbed validatePatternBindingDecl(swift::TypeChecker&, swift::PatternBindingDecl*, unsigned int) + 861
25 swift 0x0000000104d9a5fe (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 462
26 swift 0x0000000104d9a418 swift::TypeChecker::typeCheckDecl(swift::Decl*, bool) + 152
27 swift 0x0000000104de3a64 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 420
28 swift 0x0000000104de2d89 (anonymous namespace)::StmtChecker::typeCheckBody(swift::BraceStmt*&) + 25
29 swift 0x0000000104de22ef swift::TypeChecker::typeCheckConstructorBodyUntil(swift::ConstructorDecl*, swift::SourceLoc) + 879
30 swift 0x0000000104de1c55 swift::TypeChecker::typeCheckAbstractFunctionBodyUntil(swift::AbstractFunctionDecl*, swift::SourceLoc) + 37
31 swift 0x0000000104de298a swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) + 138
32 swift 0x0000000104d69a18 typeCheckFunctionsAndExternalDecls(swift::TypeChecker&) + 200
33 swift 0x0000000104d6a73c swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int) + 1772
34 swift 0x0000000104b7d565 swift::CompilerInstance::performSema() + 4133
35 swift 0x00000001047235b0 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 736
36 swift 0x00000001047230b3 frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2515
37 swift 0x000000010471f28f main + 1983
Expected Results:
The attached project should compiler successfully
Actual Results:
The Swift compiler crashes
Version:
Xcode 7.0 (7A120f)
Apple Swift version 2.0 (swiftlang-700.0.38.1 clang-700.0.53)
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!