Skip to content

swift-module-digester: always canonicalize super class types. #19590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Sep 28, 2018
Merged
8 changes: 8 additions & 0 deletions include/swift/AST/DiagnosticsModuleDiffer.def
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ ERROR(super_class_changed,none,"%0 has changed its super class from %1 to %2", (

ERROR(nominal_type_kind_changed,none,"%0 has been changed to a %1", (StringRef, StringRef))

ERROR(optional_req_changed,none,"%0 is %select{now|no longer}1 an optional requirement", (StringRef, bool))

ERROR(var_let_changed,none,"%0 changes from %select{var|let}1 to %select{let|var}1", (StringRef, bool))

ERROR(no_longer_open,none,"%0 is no longer open for subclassing", (StringRef))

ERROR(func_type_escaping_changed,none,"%0 has %select{removed|added}2 @escaping in %1", (StringRef, StringRef, bool))

#ifndef DIAG_NO_UNDEF
# if defined(DIAG)
# undef DIAG
Expand Down
5 changes: 5 additions & 0 deletions include/swift/IDE/APIDigesterData.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ class DiagnosticEngine;
namespace ide {
namespace api {

enum class KeyKind {
#define KEY(NAME) KK_##NAME,
#include "swift/IDE/DigesterEnums.def"
};

// The node kind appearing in the tree that describes the content of the SDK
enum class SDKNodeKind: uint8_t {
#define NODE_KIND(NAME, VALUE) NAME,
Expand Down
2 changes: 2 additions & 0 deletions include/swift/IDE/DigesterEnums.def
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ KEY_BOOL(IsOverriding, overriding)
KEY_BOOL(IsProtocolReq, protocolReq)
KEY_BOOL(HasDefaultArg, hasDefaultArg)
KEY_BOOL(HasSetter, hasSetter)
KEY_BOOL(IsLet, isLet)
KEY_BOOL(IsOpen, isOpen)

KEY(kind)

Expand Down
6 changes: 5 additions & 1 deletion test/api-digester/Inputs/cake.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ extension S1: P2 {}

public class C0<T1, T2, T3> {}

public class C1: C0<S1, S1, S1> {
public typealias C0Alias = C0<S1, S1, S1>

public class C1: C0Alias {
open class func foo1() {}
public weak var Ins : C1?
public unowned var Ins2 : C1 = C1()
Expand Down Expand Up @@ -76,3 +78,5 @@ public protocol PSub: PSuper {
associatedtype T
func foo()
}

public let GlobalVar = 1
24 changes: 23 additions & 1 deletion test/api-digester/Inputs/cake1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,26 @@ public class SuperClassChange: C7 {}

public class GenericClass<T> {}

public class SubGenericClass: GenericClass<P1> {}
public class SubGenericClass: GenericClass<P1> {}

@objc
public protocol ObjCProtocol {
@objc
optional func removeOptional()
@objc
func addOptional()
}

public let GlobalLetChangedToVar = 1
public var GlobalVarChangedToLet = 1

public class ClassWithOpenMember {
open class func foo() {}
open var property: Int {get { return 1}}
open func bar() {}
}

public class EscapingFunctionType {
public func removedEscaping(_ a: @escaping ()->()) {}
public func addedEscaping(_ a: ()->()) {}
}
22 changes: 22 additions & 0 deletions test/api-digester/Inputs/cake2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,25 @@ public class SuperClassChange: C8 {}
public class GenericClass<T> {}

public class SubGenericClass: GenericClass<P2> {}

@objc
public protocol ObjCProtocol {
@objc
func removeOptional()
@objc
optional func addOptional()
}

public var GlobalLetChangedToVar = 1
public let GlobalVarChangedToLet = 1

public class ClassWithOpenMember {
public class func foo() {}
public var property: Int {get { return 1}}
public func bar() {}
}

public class EscapingFunctionType {
public func removedEscaping(_ a: ()->()) {}
public func addedEscaping(_ a: @escaping ()->()) {}
}
7 changes: 7 additions & 0 deletions test/api-digester/Outputs/Cake-abi.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ cake1: Constructor fixedLayoutStruct.init(b:a:) has been removed
cake1: Func C4.foo() has been removed
cake1: Func RequiementChanges.removedFunc() has been removed
cake1: Subscript RemoveSetters.subscript(_:) has removed its setter
cake1: Var GlobalVarChangedToLet has removed its setter
cake1: Var RemoveSetters.Value has removed its setter
cake1: Var RequiementChanges.removedVar has been removed

Expand All @@ -30,6 +31,8 @@ cake1: Constructor S1.init(_:) has parameter 0 type change from Int to Double
cake1: Func C1.foo2(_:) has parameter 0 type change from Int to () -> ()
cake1: Func C7.foo(_:_:) has removed default argument from parameter 0
cake1: Func C7.foo(_:_:) has removed default argument from parameter 1
cake1: Func EscapingFunctionType.addedEscaping(_:) has added @escaping in parameter 0
cake1: Func EscapingFunctionType.removedEscaping(_:) has removed @escaping in parameter 0
cake1: Func Somestruct2.foo1(_:) has parameter 0 type change from C3 to C1

/* Decl Attribute changes */
Expand All @@ -42,6 +45,8 @@ cake1: Func S1.foo3() is now static
cake1: Struct C6 is now with @_fixed_layout
cake1: Var C1.CIIns1 changes from weak to strong
cake1: Var C1.CIIns2 changes from strong to weak
cake1: Var GlobalLetChangedToVar changes from let to var
cake1: Var GlobalVarChangedToLet changes from var to let

/* Fixed-layout Type changes */
cake1: EnumElement FrozenKind.Fixed in a non-resilient type changes position from 1 to 2
Expand All @@ -53,6 +58,8 @@ cake2: Var fixedLayoutStruct.c is added to a non-resilient type
cake2: Var fixedLayoutStruct.lazy_d.storage is added to a non-resilient type

/* Conformance changes */
cake1: Func ObjCProtocol.addOptional() is now an optional requirement
cake1: Func ObjCProtocol.removeOptional() is no longer an optional requirement
cake1: Protocol P3 has added inherited protocol P4
cake1: Protocol P3 has removed inherited protocol P2
cake1: Struct fixedLayoutStruct has removed conformance to P1
Expand Down
5 changes: 5 additions & 0 deletions test/api-digester/Outputs/Cake.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ cake1: Constructor fixedLayoutStruct.init(b:a:) has been removed
cake1: Func C4.foo() has been removed
cake1: Func RequiementChanges.removedFunc() has been removed
cake1: Subscript RemoveSetters.subscript(_:) has removed its setter
cake1: Var GlobalVarChangedToLet has removed its setter
cake1: Var RemoveSetters.Value has removed its setter
cake1: Var RequiementChanges.removedVar has been removed

Expand All @@ -38,6 +39,7 @@ cake1: Var C1.CIIns1 changes from weak to strong
cake1: Var C1.CIIns2 changes from strong to weak

/* Conformance changes */
cake1: Func ObjCProtocol.removeOptional() is no longer an optional requirement
cake1: Protocol P3 has added inherited protocol P4
cake1: Protocol P3 has removed inherited protocol P2
cake1: Struct fixedLayoutStruct has removed conformance to P1
Expand All @@ -52,3 +54,6 @@ cake2: Var RequiementChanges.addedVar has been added as a protocol requirement
cake1: Class C4 has changed its super class from OldType to NewType
cake1: Class SubGenericClass has changed its super class from GenericClass<P1> to GenericClass<P2>
cake1: Class SuperClassRemoval has removed its super class C3
cake1: Func ClassWithOpenMember.bar() is no longer open for subclassing
cake1: Func ClassWithOpenMember.foo() is no longer open for subclassing
cake1: Var ClassWithOpenMember.property is no longer open for subclassing
Loading