Files
swift-mirror/test/SILOptimizer/infinite_recursion_objc.swift
Robert Widmann 5c7b79072b Detect and diagnose infinitely-recursive code
Add a new warning that detects when a function will call itself
recursively on all code paths.  Attempts to invoke functions like this
may cause unbounded stack growth at least or undefined behavior in the
worst cases.

The detection code is implemented as DFS for a reachable exit path in
a given SILFunction.
2018-02-26 16:27:32 -05:00

21 lines
394 B
Swift

// RUN: %target-swift-frontend -emit-sil -primary-file %s -o /dev/null -verify
// REQUIRES: objc_interop
// A negative test that the infinite recursion pass doesn't diagnose dynamic
// dispatch.
import Foundation
class MyRecursiveClass {
required init() {}
@objc dynamic func foo() {
return type(of: self).foo(self)()
}
@objc dynamic func foo2() {
return self.foo()
}
}