File tree Expand file tree Collapse file tree 5 files changed +18
-12
lines changed
library-tests/type-inference Expand file tree Collapse file tree 5 files changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -74,15 +74,31 @@ abstract class Type extends TType {
7474abstract private class StructOrEnumType extends Type {
7575 abstract ItemNode asItemNode ( ) ;
7676
77- final override Function getMethod ( string name ) {
77+ pragma [ nomagic]
78+ private Function getMethodCand ( ImplOrTraitItemNode impl , string name ) {
7879 result = this .asItemNode ( ) .getASuccessor ( name ) and
79- exists ( ImplOrTraitItemNode impl | result = impl .getAnAssocItem ( ) |
80+ result = impl .getAnAssocItem ( ) and
81+ (
8082 impl instanceof Trait
8183 or
8284 impl .( ImplItemNode ) .isFullyParametric ( )
8385 )
8486 }
8587
88+ pragma [ nomagic]
89+ private Function getImplMethod ( ImplOrTraitItemNode impl , string name ) {
90+ result = this .getMethodCand ( impl , name ) and
91+ impl = any ( Impl i | not i .hasTrait ( ) )
92+ }
93+
94+ final override Function getMethod ( string name ) {
95+ result = this .getImplMethod ( _, name )
96+ or
97+ // methods from `impl` blocks shadow functions from `impl Trait` blocks
98+ result = this .getMethodCand ( _, name ) and
99+ not exists ( this .getImplMethod ( _, name ) )
100+ }
101+
86102 /** Gets all of the fully parametric `impl` blocks that target this type. */
87103 final override ImplMention getABaseTypeMention ( ) {
88104 this .asItemNode ( ) = result .resolveSelfTy ( ) and
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11testFailures
2- | main.rs:945:26:945:31 | x.m1() | Unexpected result: method=m1 |
32inferType
43| loop/main.rs:7:12:7:15 | SelfParam | | loop/main.rs:6:1:8:1 | Self [trait T1] |
54| loop/main.rs:11:12:11:15 | SelfParam | | loop/main.rs:10:1:14:1 | Self [trait T2] |
You can’t perform that action at this time.
0 commit comments