不明确时参考的getter / setter有不同的可见性 [英] Ambiguous reference when getter/setter have different visibilities

查看:141
本文介绍了不明确时参考的getter / setter有不同的可见性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面code提出了一个明确的引用在编译时:

The following code raises an ambiguous reference to value at compile time:

import flash.display.Sprite;

public class Main extends Sprite
{
    private var _value : Number = 0.;

    public  function get value() : Number           { return _value; }
    private function set value(v : Number) : void   { _value = v; }

    public function Main() : void
    {
        value = 42.;
    }
}

我怀疑某种错误的编译器,虽然我并没有真正阅读的ECMA标准。

I suspect some kind of bug in the compiler, though I didn't actually read the ECMA standard.

在有人问这些问题:

  • 在私人制定者也有意义。
  • 的模糊性也与自定义命名空间的存在(这是我面临的问题)。

推荐答案

这的确是在编译器中的一个错误,这是的在错误中列出的。它指出,开发商的一个oversite并不会很快修复任何时候。

it is indeed a bug in the compiler, and it is listed in the bugs. its stated that its an oversite of the developers and wont be fixed any time soon.

如果你需要专门跑一个函数来设置私有(而不仅仅是赋值,在这种情况下,你可以完全离开了setter函数和ITLL运行),那么你就必须运行一个单独的功能桑德罗说:

if you are needing to specifically run a function to set privately (rather than just assign the value, in which case you can leave out the setter function completely and itll run) then you will have to run a seperate function as Sandro said.

这篇关于不明确时参考的getter / setter有不同的可见性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆