Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a bug where a constructor call of an open class is devirtualized …
…although the call should be done dynamically. fixes rdar://problem/28882879
- Loading branch information
Showing
2 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// RUN: %target-swift-frontend %s -module-name test -emit-sil -o - -verify | %FileCheck %s | ||
|
||
|
||
// Constructor calls are dispatched dynamically for open classes, even if | ||
// the constructor itself is not "open". | ||
|
||
open class OpenClass { | ||
// CHECK-LABEL: sil @_TFC4test9OpenClasscfT1xSi_S0_ : $@convention(method) (Int, @owned OpenClass) -> @owned OpenClass | ||
// CHECK: [[M:%[0-9]+]] = class_method %1 : $OpenClass, #OpenClass.init!initializer.1 : (OpenClass.Type) -> (Int, Int) -> OpenClass | ||
// CHECK: apply [[M]] | ||
// CHECK: return | ||
public convenience init(x: Int) { | ||
self.init(x: x, y: 27) | ||
} | ||
public init(x: Int, y: Int) { | ||
} | ||
} | ||
|
||
// Static dispatch for not-open class (we are compiling with -wmo). | ||
|
||
public class PublicClass { | ||
// CHECK-LABEL: sil @_TFC4test11PublicClasscfT1xSi_S0_ : $@convention(method) (Int, @owned PublicClass) -> @owned PublicClass | ||
// CHECK: [[M:%[0-9]+]] = function_ref @_TFC4test11PublicClasscfT1xSi1ySi_S0_ : $@convention(method) (Int, Int, @owned PublicClass) -> @owned PublicClass | ||
// CHECK: apply [[M]] | ||
// CHECK: return | ||
public convenience init(x: Int) { | ||
self.init(x: x, y: 27) | ||
} | ||
public init(x: Int, y: Int) { | ||
} | ||
} | ||
|