From c865c64502aa92a6eb501c3fc8993d212cb944ee Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 2 Mar 2025 19:35:03 +0000 Subject: Store native type info with methods --- .../TypeCheckerNativeTypeDeclarationTests.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/test/java') diff --git a/src/test/java/org/shedlang/compiler/typechecker/TypeCheckerNativeTypeDeclarationTests.java b/src/test/java/org/shedlang/compiler/typechecker/TypeCheckerNativeTypeDeclarationTests.java index 938b6075..a02262a4 100644 --- a/src/test/java/org/shedlang/compiler/typechecker/TypeCheckerNativeTypeDeclarationTests.java +++ b/src/test/java/org/shedlang/compiler/typechecker/TypeCheckerNativeTypeDeclarationTests.java @@ -6,6 +6,7 @@ import org.shedlang.compiler.ast.untyped.UntypedNativeFunctionDeclarationNode; import org.shedlang.compiler.ast.untyped.UntypedNativeTypeDeclarationNode; import org.shedlang.compiler.typechecker.errors.CannotDefineNativeTypeOutsideOfNamespaceError; import org.shedlang.compiler.types.FunctionType; +import org.shedlang.compiler.types.MethodInfo; import org.shedlang.compiler.types.NamespaceName; import org.shedlang.compiler.types.Types; import org.shedlang.compiler.util.P; @@ -156,5 +157,19 @@ public class TypeCheckerNativeTypeDeclarationTests { ) )) ); + var nativeTypeInfo = typed.context().toTypeInfos() + .nativeTypeInfo(Types.nativeType(NAMESPACE_NAME, "ExampleType")) + .orElseThrow(); + assertThat( + nativeTypeInfo, + has("methods", x -> x.methods(), isSequence( + equalTo(new MethodInfo( + "a", + FunctionType.builder() + .withReturnType(Types.UNIT) + .build() + )) + )) + ); } } -- cgit v1.2.3