-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix super call to mixins in named constructors. (#1956)
- Loading branch information
Showing
14 changed files
with
160 additions
and
23 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
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
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
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
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
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,42 @@ | ||
// Copyright (C) 2023 Toitware ApS. | ||
// Use of this source code is governed by a Zero-Clause BSD license that can | ||
// be found in the tests/LICENSE file. | ||
|
||
import expect show * | ||
|
||
foo [block]: | ||
block.call | ||
|
||
mixin MixA: | ||
field/int? := null | ||
field2/int := 499 | ||
|
||
constructor: | ||
field = 42 | ||
|
||
mixin MixB extends MixA: | ||
foo: | ||
return field | ||
|
||
bar: | ||
return field2 | ||
|
||
class ClassA extends Object with MixA: | ||
|
||
class ClassB extends Object with MixB: | ||
b-field1 := "a" | ||
b-field2 := "b" | ||
|
||
main: | ||
a := ClassA | ||
expect-equals 42 a.field | ||
expect-equals 499 a.field2 | ||
|
||
b := ClassB | ||
expect-equals 42 b.field | ||
expect-equals 499 b.field2 | ||
expect-equals "a" b.b-field1 | ||
expect-equals "b" b.b-field2 | ||
|
||
expect-equals 42 b.foo | ||
expect-equals 499 b.bar |
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,34 @@ | ||
// Copyright (C) 2023 Toitware ApS. | ||
// Use of this source code is governed by a Zero-Clause BSD license that can | ||
// be found in the tests/LICENSE file. | ||
|
||
import expect show * | ||
|
||
events := [] | ||
|
||
mixin Mix1: | ||
constructor: | ||
events.add "Mix1" | ||
|
||
class A extends Object with Mix1: | ||
|
||
class B extends Object with Mix1: | ||
constructor: | ||
events.add "ClassB" | ||
|
||
class C extends Object with Mix1: | ||
field := 499 | ||
|
||
main: | ||
a := A | ||
expect-equals ["Mix1"] events | ||
events.clear | ||
|
||
b := B | ||
expect-equals ["ClassB", "Mix1"] events | ||
events.clear | ||
|
||
c := C | ||
expect-equals ["Mix1"] events | ||
events.clear | ||
expect-equals 499 c.field |
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,37 @@ | ||
// Copyright (C) 2023 Toitware ApS. | ||
// Use of this source code is governed by a Zero-Clause BSD license that can | ||
// be found in the tests/LICENSE file. | ||
|
||
import expect show * | ||
|
||
events := [] | ||
|
||
mixin Mix1: | ||
bool-field := false | ||
int-field := 499 | ||
|
||
mixin Mix2 extends Mix1: | ||
|
||
class A extends Object with Mix2: | ||
|
||
class B extends Object with Mix2: | ||
constructor: | ||
events.add "ClassB" | ||
|
||
class C extends Object with Mix2: | ||
field := 499 | ||
|
||
main: | ||
a := A | ||
expect-equals false a.bool-field | ||
expect-equals 499 a.int-field | ||
|
||
b := B | ||
expect-equals ["ClassB"] events | ||
expect-equals false b.bool-field | ||
expect-equals 499 b.int-field | ||
|
||
c := C | ||
expect-equals false c.bool-field | ||
expect-equals 499 c.int-field | ||
expect-equals 499 c.field |
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,15 @@ | ||
// Copyright (C) 2023 Toitware ApS. | ||
// Use of this source code is governed by a Zero-Clause BSD license that can | ||
// be found in the tests/LICENSE file. | ||
|
||
import expect show * | ||
|
||
mixin Mix1: | ||
field/int := 499 | ||
|
||
class A extends Object with Mix1: | ||
constructor.named: | ||
|
||
main: | ||
a := A.named | ||
expect-equals 499 a.field |