Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#86dt36ygt - Remove @metadata annotation #1238

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
781 changes: 382 additions & 399 deletions boa3/builtin/compile_time/__init__.py

Large diffs are not rendered by default.

15 changes: 3 additions & 12 deletions boa3/internal/analyser/moduleanalyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def _read_metadata_object(self, function: ast.FunctionDef):
self._log_warning(
CompilerWarning.RedeclaredSymbol(
line=function.lineno, col=function.col_offset,
symbol_id=Builtin.Metadata.identifier
symbol_id="metadata"
)
)
# this function must have a return and no arguments
Expand Down Expand Up @@ -633,7 +633,7 @@ def visit_Module(self, module: ast.Module):
for stmt in function_stmts:
result = self.visit(stmt)
# don't evaluate the metadata function in the following analysers
if result is Builtin.Metadata:
if result is MetadataTypeSingleton:
meevee98 marked this conversation as resolved.
Show resolved Hide resolved
module.body.remove(stmt)

self.modules['main'] = mod
Expand Down Expand Up @@ -735,15 +735,6 @@ def visit_FunctionDef(self, function: ast.FunctionDef):
:param function:
"""
fun_decorators: list[Method] = self._get_decorators(function)
if Builtin.Metadata in fun_decorators:
self._log_warning(
CompilerWarning.DeprecatedSymbol(
function.lineno, function.col_offset,
symbol_id=Builtin.Metadata.identifier
)
)
self._read_metadata_object(function)
return Builtin.Metadata

if any(decorator is None for decorator in fun_decorators):
meevee98 marked this conversation as resolved.
Show resolved Hide resolved
meevee98 marked this conversation as resolved.
Show resolved Hide resolved
self._log_error(
Expand Down Expand Up @@ -847,7 +838,7 @@ def visit_FunctionDef(self, function: ast.FunctionDef):
symbol = self.get_symbol(fun_rtype_symbol, origin_node=function.returns)
if symbol is MetadataTypeSingleton:
self._read_metadata_object(function)
return Builtin.Metadata
return symbol

fun_rtype_symbol = self.get_type(symbol)

Expand Down
2 changes: 0 additions & 2 deletions boa3/internal/model/builtin/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ def interop_symbols(cls, package: str = None) -> dict[str, IdentifiedSymbol]:
# boa builtin decorator
ContractInterface = ContractDecorator()
ContractMethodDisplayName = DisplayNameDecorator()
Metadata = MetadataDecorator()
Public = PublicDecorator()

# boa builtin type
Expand Down Expand Up @@ -286,7 +285,6 @@ def builtin_events(cls) -> list[EventSymbol]:
],
BoaPackage.CompileTime: [ContractInterface,
ContractMethodDisplayName,
Metadata,
NeoMetadataType,
Public,
NewEvent
Expand Down
2 changes: 0 additions & 2 deletions boa3/internal/model/builtin/decorator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
'ContractDecorator',
'DisplayNameDecorator',
'InstanceMethodDecorator',
'MetadataDecorator',
'PropertyDecorator',
'PublicDecorator',
'StaticMethodDecorator'
Expand All @@ -12,7 +11,6 @@
from boa3.internal.model.builtin.decorator.contractdecorator import ContractDecorator
from boa3.internal.model.builtin.decorator.displaynamedecorator import DisplayNameDecorator
from boa3.internal.model.builtin.decorator.instancemethoddecorator import InstanceMethodDecorator
from boa3.internal.model.builtin.decorator.metadatadecorator import MetadataDecorator
from boa3.internal.model.builtin.decorator.propertydecorator import PropertyDecorator
from boa3.internal.model.builtin.decorator.publicdecorator import PublicDecorator
from boa3.internal.model.builtin.decorator.staticmethoddecorator import StaticMethodDecorator
7 changes: 0 additions & 7 deletions boa3/internal/model/builtin/decorator/metadatadecorator.py

This file was deleted.

This file was deleted.

12 changes: 0 additions & 12 deletions boa3_test/test_sc/metadata_test/MetadataInfoWithDecorator.py

This file was deleted.

12 changes: 0 additions & 12 deletions boa3_test/tests/compiler_tests/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,6 @@ def test_metadata_info_method(self):
self.assertIn('extra', manifest)
self.assertIsNone(manifest['extra'])

def test_metadata_info_method_with_decorator(self):
expected_output = (
Opcode.PUSH5 # return 5
+ Opcode.RET
)

output, _ = self.assertCompilerLogs(CompilerWarning.DeprecatedSymbol, 'MetadataInfoWithDecorator.py')
self.assertEqual(expected_output, output)

def test_metadata_info_method_mismatched_type(self):
self.assertCompilerLogs(CompilerError.MismatchedTypes, 'MetadataInfoMethodMismatchedReturn.py')

def test_metadata_info_method_no_return(self):
self.assertCompilerLogs(CompilerError.MissingReturnStatement, 'MetadataInfoMethodNoReturn.py')

Expand Down
Loading