mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[CS] Quick workaround for rdar://160135085
Temporarily disable the checking requirements for typealias types, and desugar the typealias since the constraint system does not currently correctly handle type variables in the underlying type.
This commit is contained in:
@@ -268,9 +268,7 @@ public:
|
||||
auto substTy = TypeAliasType::get(
|
||||
aliasTy->getDecl(), transform(aliasTy->getParent()), genericArgs,
|
||||
transform(aliasTy->getSinglyDesugaredType()));
|
||||
openGenericTypeRequirements(substTy->getDecl(),
|
||||
substTy->getSubstitutionMap());
|
||||
return substTy;
|
||||
return substTy->getSinglyDesugaredType();
|
||||
}
|
||||
|
||||
Type transformErrorType(ErrorType *errTy) {
|
||||
|
||||
24
test/Constraints/rdar160135085.swift
Normal file
24
test/Constraints/rdar160135085.swift
Normal file
@@ -0,0 +1,24 @@
|
||||
// RUN: %empty-directory(%t/modules)
|
||||
// RUN: split-file %s %t
|
||||
|
||||
// RUN: %target-swift-frontend-emit-module -emit-module-path %t/modules/A.swiftmodule -module-name A %t/a.swift
|
||||
// RUN: %target-swift-frontend-emit-module -emit-module-path %t/modules/B.swiftmodule -module-name B -I %t/modules %t/b.swift
|
||||
// RUN: %target-swift-frontend -typecheck -I %t/modules %t/c.swift
|
||||
|
||||
//--- a.swift
|
||||
|
||||
public struct S<T> {
|
||||
public init(_ x: T) {}
|
||||
}
|
||||
|
||||
//--- b.swift
|
||||
|
||||
import A
|
||||
public typealias S = A.S
|
||||
|
||||
//--- c.swift
|
||||
|
||||
import A
|
||||
import B
|
||||
|
||||
_ = S(0)
|
||||
@@ -1,4 +1,5 @@
|
||||
// RUN: %target-typecheck-verify-swift
|
||||
// REQUIRES: rdar160135085
|
||||
|
||||
struct K<U> {} // expected-note 6{{'U' declared as parameter to type 'K'}}
|
||||
protocol Q {}
|
||||
|
||||
@@ -465,3 +465,19 @@ func testSugar(_ gx: GX<Int>, _ gy: GX<Int>.GY<Double>, gz: GX<Int>.GY<Double>.E
|
||||
let i2: Int = gy // expected-error{{cannot convert value of type 'GX<Int>.GY<Double>' (aka 'Array<Double>') to specified type 'Int'}}
|
||||
let i3: Int = gz // expected-error{{cannot convert value of type 'GX<Int>.GY<Double>.Element' (aka 'Double') to specified type 'Int'}}
|
||||
}
|
||||
|
||||
func testLocalRequirementInference<T>(_ x: T, y: Int, s: S) {
|
||||
typealias X<U: P> = (T, U) where T == U.A
|
||||
func foo<V>(_ x: X<V>) {} // expected-note {{where 'V' = 'Int'}} expected-note {{where 'T' = 'T', 'V.A' = 'S.A' (aka 'Float')}}
|
||||
foo((x, y)) // expected-error {{local function 'foo' requires that 'Int' conform to 'P'}}
|
||||
foo((x, s)) // expected-error {{local function 'foo' requires the types 'T' and 'S.A' (aka 'Float') be equivalent}}
|
||||
}
|
||||
|
||||
struct TestNestedRequirementInference<T> {
|
||||
typealias X<U: P> = (T, U) where T == U.A
|
||||
func foo<V>(_ x: X<V>) {} // expected-note {{where 'V' = 'Int'}} expected-note {{where 'T' = 'T', 'V.A' = 'S.A' (aka 'Float')}}
|
||||
func bar(_ x: T, y: Int, s: S) {
|
||||
foo((x, y)) // expected-error {{instance method 'foo' requires that 'Int' conform to 'P'}}
|
||||
foo((x, s)) // expected-error {{instance method 'foo' requires the types 'T' and 'S.A' (aka 'Float') be equivalent}}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// {"kind":"typecheck","signature":"swift::constraints::ConstraintSystem::openGenericParameters(swift::DeclContext*, swift::GenericSignature, llvm::SmallVectorImpl<std::__1::pair<swift::GenericTypeParamType*, swift::TypeVariableType*>>&, swift::constraints::ConstraintLocatorBuilder, swift::constraints::PreparedOverloadBuilder*)","signatureAssert":"Assertion failed: (sig), function openGenericParameters"}
|
||||
// RUN: not %target-swift-frontend -typecheck %s
|
||||
class a<b
|
||||
func c -> d
|
||||
typealias c : a
|
||||
c
|
||||
@@ -0,0 +1,8 @@
|
||||
// {"kind":"typecheck","original":"0df5dc82","signature":"swift::constraints::ConstraintSystem::typeVarOccursInType(swift::TypeVariableType*, swift::Type, bool*)","signatureAssert":"Assertion failed: ((!typeVariables.empty() || hasError()) && \"Did not find type variables!\"), function getTypeVariables"}
|
||||
// RUN: not %target-swift-frontend -typecheck %s
|
||||
struct a<each b {
|
||||
typealias d<c> = (
|
||||
> func 1 {
|
||||
typealias e = f
|
||||
e
|
||||
typealias e = d
|
||||
Reference in New Issue
Block a user