Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion lib/AST/ASTPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2781,8 +2781,13 @@ void PrintAST::printEnumElement(EnumElementDecl *elt) {
->castTo<AnyFunctionType>()
->getParams();
}

// @escaping is not valid in enum element position, even though the
// attribute is implicitly added. Ignore it when printing the parameters.
Options.ExcludeAttrList.push_back(TAK_escaping);
printParameterList(PL, params,
/*isAPINameByDefault*/true);
Options.ExcludeAttrList.pop_back();
}

auto *raw = elt->getRawValueExpr();
Expand Down Expand Up @@ -3375,7 +3380,11 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
if (!Options.FullyQualifiedTypesIfAmbiguous)
return false;

Decl *D = T->getAnyGeneric();
Decl *D;
if (auto *TAT = dyn_cast<TypeAliasType>(T))
D = TAT->getDecl();
else
D = T->getAnyGeneric();

// If we cannot find the declaration, be extra careful and print
// the type qualified.
Expand Down Expand Up @@ -3507,6 +3516,8 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
if (auto parent = T->getParent()) {
visit(parent);
Printer << ".";
} else if (shouldPrintFullyQualified(T)) {
printModuleContext(T);
}

printTypeDeclName(T);
Expand Down Expand Up @@ -4024,6 +4035,10 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
}

void visitProtocolType(ProtocolType *T) {
if (shouldPrintFullyQualified(T)) {
printModuleContext(T);
}

printTypeDeclName(T);
}

Expand Down
4 changes: 2 additions & 2 deletions test/IDE/print_swift_module.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public func returnsAlias() -> Alias<Int> {
// CHECK1: /// Alias comment
// CHECK1-NEXT: typealias Alias<T> = (T, T)

// CHECK1: public class C1 : P1 {
// CHECK1: public class C1 : print_swift_module.P1 {
// CHECK1-NEXT: /// foo1 comment from P1
// CHECK1-NEXT: public func foo1()
// CHECK1-NEXT: /// foo2 comment from C1
Expand All @@ -43,4 +43,4 @@ public func returnsAlias() -> Alias<Int> {
// CHECK1-NEXT: }

// CHECK1: /// returnsAlias() comment
// CHECK1-NEXT: func returnsAlias() -> Alias<Int>
// CHECK1-NEXT: func returnsAlias() -> print_swift_module.Alias<Int>
8 changes: 4 additions & 4 deletions test/IDE/print_synthesized_extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ extension S13 : P5 {
// CHECK4-NEXT: <decl:Func>public func <loc>S9IntFunc()</loc></decl>
// CHECK4-NEXT: }</synthesized>

// CHECK5: <decl:Struct>public struct <loc>S10</loc> : <ref:Protocol>P1</ref> {
// CHECK5: <decl:Struct>public struct <loc>S10</loc> : <ref:module>print_synthesized_extensions</ref>.<ref:Protocol>P1</ref> {
// CHECK5-NEXT: <decl:TypeAlias>public typealias <loc>T1</loc> = <ref:module>print_synthesized_extensions</ref>.<ref:Struct>S9</ref><<ref:Struct>Int</ref>></decl>
// CHECK5-NEXT: <decl:TypeAlias>public typealias <loc>T2</loc> = <ref:module>print_synthesized_extensions</ref>.<ref:Struct>S9</ref><<ref:Struct>Int</ref>></decl>
// CHECK5-NEXT: <decl:Func>public func <loc>f1(<decl:Param>t: <ref:module>print_synthesized_extensions</ref>.<ref:Struct>S10</ref>.<ref:TypeAlias>T1</ref></decl>)</loc> -> <ref:module>print_synthesized_extensions</ref>.<ref:Struct>S10</ref>.<ref:TypeAlias>T1</ref></decl>
Expand All @@ -275,15 +275,15 @@ extension S13 : P5 {
// CHECK7-NEXT: <decl:Func>public func <loc>P4Func2()</loc></decl>
// CHECK7-NEXT: }</synthesized>

// CHECK8: <decl:Struct>public struct <loc>S4<<decl:GenericTypeParam>T</decl>></loc> : <ref:Protocol>P1</ref> {
// CHECK8: <decl:Struct>public struct <loc>S4<<decl:GenericTypeParam>T</decl>></loc> : <ref:module>print_synthesized_extensions</ref>.<ref:Protocol>P1</ref> {
// CHECK8-NEXT: <decl:TypeAlias>public typealias <loc>T1</loc> = <ref:Struct>Int</ref></decl>
// CHECK8-NEXT: <decl:TypeAlias>public typealias <loc>T2</loc> = <ref:Struct>Int</ref></decl>
// CHECK8-NEXT: <decl:Func>public func <loc>f1(<decl:Param>t: <ref:module>print_synthesized_extensions</ref>.<ref:Struct>S4</ref><T>.<ref:TypeAlias>T1</ref></decl>)</loc> -> <ref:module>print_synthesized_extensions</ref>.<ref:Struct>S4</ref><T>.<ref:TypeAlias>T1</ref></decl>
// CHECK8-NEXT: <decl:Func>public func <loc>f2(<decl:Param>t: <ref:module>print_synthesized_extensions</ref>.<ref:Struct>S4</ref><T>.<ref:TypeAlias>T2</ref></decl>)</loc> -> <ref:module>print_synthesized_extensions</ref>.<ref:Struct>S4</ref><T>.<ref:TypeAlias>T2</ref></decl></decl>
// CHECK8-NEXT: <decl:Func>public func <loc>p1IntFunc(<decl:Param>i: <ref:Struct>Int</ref></decl>)</loc> -> <ref:Struct>Int</ref></decl>
// CHECK8-NEXT: }</synthesized>

// CHECK9: <decl:Struct>public struct <loc>S6<<decl:GenericTypeParam>T</decl>></loc> : <ref:Protocol>P1</ref> {
// CHECK9: <decl:Struct>public struct <loc>S6<<decl:GenericTypeParam>T</decl>></loc> : <ref:module>print_synthesized_extensions</ref>.<ref:Protocol>P1</ref> {
// CHECK9-NEXT: <decl:TypeAlias>public typealias <loc>T1</loc> = <ref:module>print_synthesized_extensions</ref>.<ref:Struct>S5</ref></decl>
// CHECK9-NEXT: <decl:TypeAlias>public typealias <loc>T2</loc> = <ref:module>print_synthesized_extensions</ref>.<ref:Struct>S5</ref></decl>
// CHECK9-NEXT: <decl:Func>public func <loc>f1(<decl:Param>t: <ref:module>print_synthesized_extensions</ref>.<ref:Struct>S6</ref><T>.<ref:TypeAlias>T1</ref></decl>)</loc> -> <ref:module>print_synthesized_extensions</ref>.<ref:Struct>S6</ref><T>.<ref:TypeAlias>T1</ref></decl>
Expand All @@ -300,7 +300,7 @@ extension S13 : P5 {
// CHECK10-NEXT: <decl:Func>public func <loc>ef5(<decl:Param>t: <ref:Struct>S5</ref></decl>)</loc></decl>
// CHECK10-NEXT: }</synthesized>

// CHECK11: <decl:Struct>public struct <loc>S12</loc> : <ref:Protocol>P5</ref> {
// CHECK11: <decl:Struct>public struct <loc>S12</loc> : <ref:module>print_synthesized_extensions</ref>.<ref:Protocol>P5</ref> {
// CHECK11-NEXT: <decl:TypeAlias>public typealias <loc>T1</loc> = <ref:Struct>Int</ref></decl>
// CHECK11-NEXT: <decl:Func>/// This is picked
// CHECK11-NEXT: public func <loc>foo1()</loc></decl></decl>
Expand Down
12 changes: 6 additions & 6 deletions test/IDE/print_types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

typealias MyInt = Int
// CHECK: TypeAliasDecl '''MyInt''' MyInt.Type{{$}}
// FULL: TypeAliasDecl '''MyInt''' MyInt.Type{{$}}
// FULL: TypeAliasDecl '''MyInt''' swift_ide_test.MyInt.Type{{$}}

func testVariableTypes(_ param: Int, param2: inout Double) {
// CHECK: FuncDecl '''testVariableTypes''' (Int, inout Double) -> (){{$}}
Expand Down Expand Up @@ -52,7 +52,7 @@ func testVariableTypes(_ param: Int, param2: inout Double) {
var typealias1 : MyInt = 42
// CHECK: VarDecl '''typealias1''' MyInt{{$}}
// CHECK: IntegerLiteralExpr:[[@LINE-2]] '''42''' Int{{$}}
// FULL: VarDecl '''typealias1''' MyInt{{$}}
// FULL: VarDecl '''typealias1''' swift_ide_test.MyInt{{$}}
// FULL: IntegerLiteralExpr:[[@LINE-4]] '''42''' Swift.Int{{$}}
_ = typealias1 ; typealias1 = 1

Expand All @@ -77,11 +77,11 @@ func testFuncType2() -> () {}

func testFuncType3() -> Void {}
// CHECK: FuncDecl '''testFuncType3''' () -> Void{{$}}
// FULL: FuncDecl '''testFuncType3''' () -> Void{{$}}
// FULL: FuncDecl '''testFuncType3''' () -> Swift.Void{{$}}

func testFuncType4() -> MyInt {}
// CHECK: FuncDecl '''testFuncType4''' () -> MyInt{{$}}
// FULL: FuncDecl '''testFuncType4''' () -> MyInt{{$}}
// FULL: FuncDecl '''testFuncType4''' () -> swift_ide_test.MyInt{{$}}

func testFuncType5() -> (Int) {}
// CHECK: FuncDecl '''testFuncType5''' () -> (Int){{$}}
Expand Down Expand Up @@ -111,7 +111,7 @@ struct GenericStruct<A, B : FooProtocol> {}

func testInGenericFunc1<A, B : FooProtocol, C : FooProtocol & BarProtocol>(_ a: A, b: B, c: C) {
// CHECK: FuncDecl '''testInGenericFunc1''' <A, B, C where B : FooProtocol, C : BarProtocol, C : FooProtocol> (A, b: B, c: C) -> (){{$}}
// FULL: FuncDecl '''testInGenericFunc1''' <A, B, C where B : FooProtocol, C : BarProtocol, C : FooProtocol> (A, b: B, c: C) -> (){{$}}
// FULL: FuncDecl '''testInGenericFunc1''' <A, B, C where B : swift_ide_test.FooProtocol, C : swift_ide_test.BarProtocol, C : swift_ide_test.FooProtocol> (A, b: B, c: C) -> (){{$}}

var a1 = a
_ = a1; a1 = a
Expand All @@ -136,5 +136,5 @@ func testInGenericFunc1<A, B : FooProtocol, C : FooProtocol & BarProtocol>(_ a:

func testInGenericFunc2<T : QuxProtocol, U : QuxProtocol>(_: T, _: U) where T.Qux == U.Qux {}
// CHECK: FuncDecl '''testInGenericFunc2''' <T, U where T : QuxProtocol, U : QuxProtocol, T.Qux == U.Qux> (T, U) -> (){{$}}
// FULL: FuncDecl '''testInGenericFunc2''' <T, U where T : QuxProtocol, U : QuxProtocol, T.Qux == U.Qux> (T, U) -> (){{$}}
// FULL: FuncDecl '''testInGenericFunc2''' <T, U where T : swift_ide_test.QuxProtocol, U : swift_ide_test.QuxProtocol, T.Qux == U.Qux> (T, U) -> (){{$}}

2 changes: 1 addition & 1 deletion test/ParseableInterface/ParseStdlib.swiftinterface
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
// RUN: %target-swift-frontend -build-module-from-parseable-interface -o %t/ParseStdlib.swiftmodule %s
// RUN: %target-swift-ide-test -print-module -module-to-print ParseStdlib -I %t -source-filename x -print-interface | %FileCheck %s

// CHECK: func test(_: Int42)
// CHECK: func test(_: Builtin.Int42)
public func test(_: Builtin.Int42) {}
8 changes: 4 additions & 4 deletions test/ParseableInterface/access-filter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,12 @@ extension GenericStruct where InternalStruct_BAD == T {
@usableFromInline internal func constrainedToInternalStruct2_BAD() {}
}

// CHECK: extension GenericStruct where T : PublicProto {{[{]$}}
// CHECK: extension GenericStruct where T : main.PublicProto {{[{]$}}
extension GenericStruct where T: PublicProto {
// CHECK-NEXT: public func constrainedToPublicProto(){{$}}
public func constrainedToPublicProto() {}
} // CHECK-NEXT: {{^[}]$}}
// CHECK: extension GenericStruct where T : UFIProto {{[{]$}}
// CHECK: extension GenericStruct where T : main.UFIProto {{[{]$}}
extension GenericStruct where T: UFIProto {
// CHECK-NEXT: @usableFromInline{{$}}
// CHECK-NEXT: internal func constrainedToUFIProto(){{$}}
Expand Down Expand Up @@ -245,12 +245,12 @@ internal typealias InternalAlias_BAD = PublicAliasBase

internal typealias ReallyInternalAlias_BAD = ReallyInternalAliasBase_BAD

// CHECK: extension GenericStruct where T == PublicAlias {{[{]$}}
// CHECK: extension GenericStruct where T == main.PublicAlias {{[{]$}}
extension GenericStruct where T == PublicAlias {
// CHECK-NEXT: public func constrainedToPublicAlias(){{$}}
public func constrainedToPublicAlias() {}
} // CHECK-NEXT: {{^[}]$}}
// CHECK: extension GenericStruct where T == UFIAlias {{[{]$}}
// CHECK: extension GenericStruct where T == main.UFIAlias {{[{]$}}
extension GenericStruct where T == UFIAlias {
// CHECK-NEXT: @usableFromInline{{$}}
// CHECK-NEXT: internal func constrainedToUFIAlias(){{$}}
Expand Down
34 changes: 17 additions & 17 deletions test/ParseableInterface/conformances.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@ public struct A1: PublicProto, PrivateProto {}
// NEGATIVE-NOT: extension conformances.A2
public struct A2: PrivateProto, PublicProto {}
// CHECK: public struct A3 {
// CHECK-END: extension conformances.A3 : PublicProto {}
// CHECK-END: extension conformances.A3 : conformances.PublicProto {}
public struct A3: PublicProto & PrivateProto {}
// CHECK: public struct A4 {
// CHECK-END: extension conformances.A4 : PublicProto {}
// CHECK-END: extension conformances.A4 : conformances.PublicProto {}
public struct A4: PrivateProto & PublicProto {}

public protocol PublicBaseProto {}
private protocol PrivateSubProto: PublicBaseProto {}

// CHECK: public struct B1 {
// CHECK-END: extension conformances.B1 : PublicBaseProto {}
// CHECK-END: extension conformances.B1 : conformances.PublicBaseProto {}
public struct B1: PrivateSubProto {}
// CHECK: public struct B2 : PublicBaseProto {
// NEGATIVE-NOT: extension conformances.B2
public struct B2: PublicBaseProto, PrivateSubProto {}
// CHECK: public struct B3 {
// CHECK-END: extension conformances.B3 : PublicBaseProto {}
// CHECK-END: extension conformances.B3 : conformances.PublicBaseProto {}
public struct B3: PublicBaseProto & PrivateSubProto {}
// CHECK: public struct B4 : PublicBaseProto {
// CHECK: extension B4 {
Expand Down Expand Up @@ -87,26 +87,26 @@ public struct OuterGeneric<T> {
public protocol ConditionallyConformed {}
public protocol ConditionallyConformedAgain {}

// CHECK-END: extension conformances.OuterGeneric : ConditionallyConformed, ConditionallyConformedAgain where T : _ConstraintThatIsNotPartOfTheAPIOfThisLibrary {}
// CHECK-END: extension conformances.OuterGeneric : conformances.ConditionallyConformed, conformances.ConditionallyConformedAgain where T : _ConstraintThatIsNotPartOfTheAPIOfThisLibrary {}
extension OuterGeneric: ConditionallyConformed where T: PrivateProto {}
extension OuterGeneric: ConditionallyConformedAgain where T == PrivateProto {}

// CHECK-END: extension conformances.OuterGeneric.Inner : PublicBaseProto {}
// CHECK-END: extension conformances.OuterGeneric.Inner : ConditionallyConformed, ConditionallyConformedAgain where T : _ConstraintThatIsNotPartOfTheAPIOfThisLibrary {}
// CHECK-END: extension conformances.OuterGeneric.Inner : conformances.PublicBaseProto {}
// CHECK-END: extension conformances.OuterGeneric.Inner : conformances.ConditionallyConformed, conformances.ConditionallyConformedAgain where T : _ConstraintThatIsNotPartOfTheAPIOfThisLibrary {}
extension OuterGeneric.Inner: ConditionallyConformed where T: PrivateProto {}
extension OuterGeneric.Inner: ConditionallyConformedAgain where T == PrivateProto {}

private protocol AnotherPrivateSubProto: PublicBaseProto {}

// CHECK: public struct C1 {
// CHECK-END: extension conformances.C1 : PublicBaseProto {}
// CHECK-END: extension conformances.C1 : conformances.PublicBaseProto {}
public struct C1: PrivateSubProto, AnotherPrivateSubProto {}
// CHECK: public struct C2 {
// CHECK-END: extension conformances.C2 : PublicBaseProto {}
// CHECK-END: extension conformances.C2 : conformances.PublicBaseProto {}
public struct C2: PrivateSubProto & AnotherPrivateSubProto {}
// CHECK: public struct C3 {
// CHECK: extension C3 {
// CHECK-END: extension conformances.C3 : PublicBaseProto {}
// CHECK-END: extension conformances.C3 : conformances.PublicBaseProto {}
public struct C3: PrivateSubProto {}
extension C3: AnotherPrivateSubProto {}

Expand All @@ -120,10 +120,10 @@ public struct D1: PublicSubProto, PrivateSubProto {}
// NEGATIVE-NOT: extension conformances.D2
public struct D2: PrivateSubProto, PublicSubProto {}
// CHECK: public struct D3 {
// CHECK-END: extension conformances.D3 : PublicBaseProto, PublicSubProto {}
// CHECK-END: extension conformances.D3 : conformances.PublicBaseProto, conformances.PublicSubProto {}
public struct D3: PrivateSubProto & PublicSubProto {}
// CHECK: public struct D4 {
// CHECK-END: extension conformances.D4 : APublicSubProto, PublicBaseProto {}
// CHECK-END: extension conformances.D4 : conformances.APublicSubProto, conformances.PublicBaseProto {}
public struct D4: APublicSubProto & PrivateSubProto {}
// CHECK: public struct D5 {
// CHECK: extension D5 : PublicSubProto {
Expand All @@ -139,33 +139,33 @@ extension D6: PrivateSubProto {}
private typealias PrivateProtoAlias = PublicProto

// CHECK: public struct E1 {
// CHECK-END: extension conformances.E1 : PublicProto {}
// CHECK-END: extension conformances.E1 : conformances.PublicProto {}
public struct E1: PrivateProtoAlias {}

private typealias PrivateSubProtoAlias = PrivateSubProto

// CHECK: public struct F1 {
// CHECK-END: extension conformances.F1 : PublicBaseProto {}
// CHECK-END: extension conformances.F1 : conformances.PublicBaseProto {}
public struct F1: PrivateSubProtoAlias {}

private protocol ClassConstrainedProto: PublicProto, AnyObject {}

public class G1: ClassConstrainedProto {}
// CHECK: public class G1 {
// CHECK-END: extension conformances.G1 : PublicProto {}
// CHECK-END: extension conformances.G1 : conformances.PublicProto {}

public class Base {}
private protocol BaseConstrainedProto: Base, PublicProto {}

public class H1: Base, ClassConstrainedProto {}
// CHECK: public class H1 : Base {
// CHECK-END: extension conformances.H1 : PublicProto {}
// CHECK-END: extension conformances.H1 : conformances.PublicProto {}

public struct MultiGeneric<T, U, V> {}
extension MultiGeneric: PublicProto where U: PrivateProto {}

// CHECK: public struct MultiGeneric<T, U, V> {
// CHECK-END: extension conformances.MultiGeneric : PublicProto where T : _ConstraintThatIsNotPartOfTheAPIOfThisLibrary {}
// CHECK-END: extension conformances.MultiGeneric : conformances.PublicProto where T : _ConstraintThatIsNotPartOfTheAPIOfThisLibrary {}


internal struct InternalImpl_BAD: PrivateSubProto {}
Expand Down
5 changes: 4 additions & 1 deletion test/ParseableInterface/inlinable-function.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
// RUN: %target-swift-frontend -emit-module -o /dev/null -merge-modules %t/Test.swiftmodule -disable-objc-attr-requires-foundation-module -emit-parseable-module-interface-path %t/TestFromModule.swiftinterface -module-name Test
// RUN: %FileCheck %s --check-prefix FROMMODULE --check-prefix CHECK < %t/TestFromModule.swiftinterface

// CHECK: public struct Foo : Hashable {
// FIXME: These shouldn't be different, or we'll get different output from
// WMO and non-WMO builds.
// FROMSOURCE-LABEL: public struct Foo : Hashable {
// FROMMODULE-LABEL: public struct Foo : Swift.Hashable {
public struct Foo: Hashable {
// CHECK: public var inlinableGetPublicSet: [[INT:(Swift.)?Int]] {
public var inlinableGetPublicSet: Int {
Expand Down
2 changes: 1 addition & 1 deletion test/SILGen/witness_accessibility_multi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import witness_accessibility_other
// CHECK-LABEL: sil [ossa] @$s27witness_accessibility_multi22callsPublicRequirement1sy0a1_B6_other1SV_tF : $@convention(thin) (S) -> ()
public func callsPublicRequirement(s: S) {

// CHECK: witness_method $S, #P.publicRequirement!1 : <Self where Self : P> (Self) -> () -> () : $@convention(witness_method: P) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> ()
// CHECK: witness_method $S, #P.publicRequirement!1 : <Self where Self : witness_accessibility_other.P> (Self) -> () -> () : $@convention(witness_method: P) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> ()
s.publicRequirement()

// CHECK: function_ref @$s27witness_accessibility_other1QPAAE19internalRequirementyyF : $@convention(method) <τ_0_0 where τ_0_0 : Q> (@in_guaranteed τ_0_0) -> ()
Expand Down
Loading