Files
swift-mirror/validation-test/compiler_crashers_2_fixed/rdar87121502.swift
Robert Widmann ad94cbd415 Add a Recursion Breaker to Opaque Type Substitution
The current check in MiscDiagnostics can only handle local 2-cycles as in:

func foo() -> some P { return bar() }
func bar() -> some P { return foo() }

Larger cycles, such as the 3-cycle present in the validation test in this patch cannot be detected without resolving all substitutions up front. Therefore, we take the tact that we can at least prevent the compiler from crashing. At runtime, instead, type resolution will blow out the stack.

The check here is simple: Plumb through a set of opaque type decls that the resolution machinery has already seen, and if we encounter a recursive opaque type substitution bail with the original opaque type.

rdar://87121502
2022-01-25 13:01:39 -08:00

17 lines
252 B
Swift

// RUN: %target-swift-frontend -emit-ir -target %target-cpu-apple-macosx10.15 %s
// REQUIRES: OS=macosx
protocol P {}
func one() -> some P {
return two()
}
func two() -> some P {
return three()
}
func three() -> some P {
return one()
}